package ch02;

import org.junit.Test;

import java.util.Date;
import java.util.Random;
import java.util.Scanner;

public class TypeTest {
    //junit注解：这是一个测试用例
    @Test
    public void testBoolean() {
        boolean b1 = true;
        boolean b2 = false;

        System.out.println(b1);
        // if for
    }

    @Test
    public void testChar() {
        //字符 - 数字
        char c1 = 'a';
        char c2 = '1';
        char c3 = '+';
        char c4 = '中';
        char c5 = ' ';
        char c6 = '\'';
        char c7 = '\\';
        char c8 = '\n';
        System.out.println("-" + c1 + "-");

        char c9 = 97;
        System.out.println(c4 + "0");
    }

    @Test
    public void testInt() {
        // 内存8G 1G=1024M  1M=1024KB  1KB=1024B
        // 8G = 8*1024*1024*1024*8 = 687 1947 6736 bit
        // 687亿 个0或1
        // 10个亿

        //整数 - 数字
        byte b = 10;   //1字节 8位 -128~127
        short s = 10;  //2字节 16位 -32768~32767
        int i = 10;    //4字节 32位 -2147483648~2147483647
        long l = 100000000000000l;   //8字节 64位 -9223372036854775808~9223372036854775807

        byte age = 25;
        age = (byte) (age + 1);

        System.out.println(age);
    }

    @Test
    public void testDouble() {
        //浮点数 - 数字
//        float f=1.1F;   //4字节 32位
//        double d=1.123;   //8字节 64位

//        System.out.println(f);
//        System.out.println(d);

        int x = -2147483648;//32位
        //2147483650
        float f = x;//32位

        x = x - 1;
        System.out.println(x);
    }

    @Test
    public void testAdd() {
        //++ --
        int i = 10;
        int j = 20;
       i++;
       i+=2; //i=i+2;

        long l=0xfffL;
        System.out.println(l);
    }

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);

        int x=scanner.nextInt();
        int y=scanner.nextInt();
        if(x>y) {
            System.out.println(x+">"+y);
        }else {
            System.out.println(x+"<="+y);
        }
    }

    @Test
    public void testIf() {
        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();
        int y = scanner.nextInt();
        if (x > y){
            System.out.println(x + ">" + y);
        System.out.println(x + ">" + y);
        }else if(x<y){
            System.out.println(x+"<"+y);
        }else{
            System.out.println(x+"="+y);
        }
    }

    @Test
    public void testIf2(){
        Date now=new Date();
        if(now.getDay()==1){
            System.out.println("星期一");
        }else if(now.getDay()==2){
            System.out.println("星期二");
        }else if(now.getDay()==3){
            System.out.println("星期三");
        } else if(now.getDay()==4) {
            System.out.println("星期四");
        } else if(now.getDay()==5) {
            System.out.println("星期五");
        } else if(now.getDay()==6) {
            System.out.println("星期六");
        } else if(now.getDay()==0) {
            System.out.println("星期日");
        }
    }
    @Test
    public void testSwitch(){
        Date now=new Date();
        // byte short int char String 枚举enum
        switch (now.getDay()){
            case 1:
                System.out.println("星期一");
                break;
            case 2:
                System.out.println("星期二");
                break;
            default:
                System.out.println("星期三");
                break;
        }
    }

    @Test
    public void testFor(){
        char c1='中';
        int sum=0;
        for ( int i=1; i <= 100; i++) {
            System.out.println(i+":"+sum);
            sum+=i;
        }
        System.out.println(sum);
    }

    @Test
    public void testForChar(){
        for (char i = 19999; i <=40000 ; i++) {
            System.out.print(i);
            if(i%200==0)
                System.out.println();
        }
    }

    @Test
    public void testRandom(){
        int x = 5;
        int result = 0;

        result = x++ + ++x - x-- - --x;

        System.out.println("The result is: " + result);

    }

}
